<?php
/**
 * @property ParamSirt $ParamSirt
 */
class ParamSirtsController extends AppController {

	var $name = 'ParamSirts';
	var $helpers = array('Js');

  /**
   * INDEX
   */
	function index() {
		$this->ParamSirt->recursive = 0;
		$this->set('paramSirts', $this->paginate());
	}

  /**
   * VIEW
   * @param type $id 
   */
	function view($id = null) {
		if (!$id) {
			$this->Session->setFlash(__('Invalid param sirt', true));
			$this->redirect(array('action' => 'index'));
		}
		$this->set('paramSirt', $this->ParamSirt->read(null, $id));
	}

  /**
   * ADD
   */
	function add() {
		if (!empty($this->data)) {
			$this->ParamSirt->create();
			if ($this->ParamSirt->save($this->data)) {
				$this->Session->setFlash(__('The param sirt has been saved', true));
				$this->redirect(array('action' => 'index'));
			} else {
				$this->Session->setFlash(__('The param sirt could not be saved. Please, try again.', true));
			}
		}
		$paramSirtBases = $this->ParamSirt->ParamSirtBasis->find('list');
		$job_versions = $this->ParamSirt->JobVersion->find('list');
		$this->set(compact('paramSirtBases', 'job_versions'));
	}

  /**
   * EDIT
   * @param type $id 
   */
	function edit($id = null) {
		if (!$id && empty($this->data)) {
			$this->Session->setFlash(__('Invalid param sirt', true));
			$this->redirect(array('action' => 'index'));
		}
		if (!empty($this->data)) {
			if ($this->ParamSirt->save($this->data)) {
				$this->Session->setFlash(__('The param sirt has been saved', true));
				$this->redirect(array('action' => 'index'));
			} else {
				$this->Session->setFlash(__('The param sirt could not be saved. Please, try again.', true));
			}
		}
		if (empty($this->data)) {
			$this->data = $this->ParamSirt->read(null, $id);
		}
		$paramSirtBases = $this->ParamSirt->ParamSirtBasis->find('list');
		$job_versions = $this->ParamSirt->JobVersion->find('list');
		$this->set(compact('paramSirtBases', 'job_versions'));
	}

  /**
   * EDIT
   * @param type $id 
   */
	function delete($id = null) {
		if (!$id) {
			$this->Session->setFlash(__('Invalid id for param sirt', true));
			$this->redirect(array('action'=>'index'));
		}
		if ($this->ParamSirt->delete($id)) {
			$this->Session->setFlash(__('Param sirt deleted', true));
			$this->redirect(array('action'=>'index'));
		}
		$this->Session->setFlash(__('Param sirt was not deleted', true));
		$this->redirect(array('action' => 'index'));
	}
}
